<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>金融资产信息</title>
	<link rel="stylesheet" href="../../js/bower_components/bootstrap/dist/css/bootstrap.min.css">
	<link rel="stylesheet" href="../../js/bower_components/bootstrap-select/dist/css/bootstrap-select.min.css">
	<link rel="stylesheet"
		href="../../js/bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css">
	<link rel="stylesheet" href="../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.css">
	<link rel="stylesheet" href="../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.css">

	<script src="../../js/bower_components/jquery/dist/jquery.min.js"></script>
	<script src="../../js/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
	<script src="../../js/bower_components/bootbox.min.js"></script>
	<script src="../../js/bower_components/bootstrap-select/js/bootstrap-select.js"></script>
	<script src="../../js/bower_components/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
	<script src="../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.js"></script>
	<script src="../../js/bower_components/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script>
	<script src="../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
	<script src="../../js/bower_components/jquery-form-validator/form-validator/jquery.form-validator.min.js"></script>
	<script src="../../js/bower_components/moment/min/moment-with-locales.min.js"></script>
	<script>
        $(function () {
            $("#btnAdd").click(function () {
                console.log("模态框的打开方法===1");
                $("#divForm").modal();
                console.log("模态框的打开方法===2");
            })
            $("#btnInstockShow").click(function () {
                console.log("模态框的打开方法===3");
                $("#divAssetsInstock").modal();
                console.log("模态框的打开方法===4");
            })
            $("#btnEdit").click(function () {
                console.log("模态框的打开方法===5");
                $("#divAssetsInfo").modal();
                console.log("模态框的打开方法===6");
            })

           //搜索按钮
			$("#btnSearch").click(function () {
				console.log("进入搜索按钮的方法");
				//获取界面当中的控件的值
				var form = $("#txt").val();
				console.log(form);
				var formorganization = $("#selorganization").selectpicker('val');
				console.log(formorganization);
				//整理查询条件
				var user = "?";
				if (form != "") {
					user += "=" + form
					if (formorganization != "" || formorganization != "全部") {
						user += "&organization=" + formorganization
					}
				}
				else if (formorganization != "") {
					if (formorganization != "全部") {
						if (user != "") {
							user += "&organization=" + formorganization
						} else {
							user += "organization=" + formorganization
						}
					}
				}

				console.log(user);

				//到后端去查询

				$.ajax({
					type: "get",
					dataType: "json",
					url: "http://121.37.241.58:8883/logic/baseInfo/category/list/4" + user,
					success: function (res) {
						inittable(res);
					}
				})
			})

			initorganization();
			inittable("");
			initorganizationForm();
		});

		function initorganization() {
			$("#selorganization").empty;
			$.ajax({
				type: "get",
				url: "http://121.37.241.58:8883/logic/baseInfo/category/list/4",
				dataType: "json",
				success: function (res) {
					console.log(res);
					if (!res.flag) {
						$.each(res, function (i, n) {
							$("#selorganization").append("<option value=\"" + n.organization + "\">" + n.organization + "</option>")
						});
						$("#selorganization").append("<option value='全部'>全部</option>");
						$("#selorganization").selectpicker('refresh');
					}
				}
			})
		}


		function initorganizationForm() {
			$("#selorganizationForm").empty;
			$.ajax({
				type: "get",
				url: "",
				dataType: "json",
				success: function (res) {
					console.log(res);
					if (!res.flag) {
						$.each(res, function (i, n) {
							$("#selorganizationForm").append("<option value=\"" + n.organization + "\">" + n.organization + "</option>")
						});
						$("#selorganizationForm").selectpicker('refresh');
					}
				}
			})
		}


		function inittable(myData) {
			console.log(myData + ":默认值")
			$("#tblResult").bootstrapTable("destroy");
			var form = $("#txt").val();
			var formorganization = $("#selorganization").selectpicker('val');
			if (myData == "") {
				if (form == "" || formorganization == "") {
					console.log("进入无参的方法")
					$("#tblResult").bootstrapTable({
						loadMsg: "正在加载数据....",
						url: "",
						//data:res,
						sidePagination: 'client',
						pageSize: "6",
						Pageinatin: true,
						idField: "id",
						columns: [{
							field: "code",
							title: "编码",
							halign: 'center'
						}, {
							field: "namecn",
							title: "资产名称",
							halign: 'center'
						}, {
							field: "organization",
							title: "购买机构",
							halign: 'center'
						}, {
							field: "cycle",
							title: "周期",
							halign: 'center'
						}, {
							field: "comment",
							title: "查询结果",
							halign: 'center'
						}
						]

					})
				} else {
					console.log("进入无参的方法")

					$("#tblResult").bootstrapTable({
						loadMsg: "正在加载数据....",
						//url:"http://121.37.241.8:8883/logic/baseInfo/category/list/4",
						data: myData,
						sidePagination: 'client',
						pageSize: "",
						Pageinatin: true,
						idField: "id",
						columns: [{
							field: "code",
							title: "编码",
							halign: 'center'
						}, {
							field: "namecn",
							title: "资产名称",
							halign: 'center'
						}, {
							field: "organization",
							title: "购买机构",
							halign: 'center'
						}, {
							field: "comment",
							title: "关联账号",
							halign: 'center'
						}, {
							field: "cycle",
							title: "周期",
							halign: 'center'
						}, {
							field: "comment",
							title: "查询结果",
							halign: 'center'
						}]
					})
				}
			} else {
				console.log("进入条件查询");
				$("#tblResult").bootstrapTable({
					loadMsg: "正在加载数据....",
					//url:"http://121.37.241.8:8883/logic/baseInfo/category/list/{4}",
					data: myData,
					sidePagination: 'client',
					pageSize: "",
					Pageinatin: true,
					idField: "id",
					columns: [{
						field: "code",
						title: "编码",
						halign: 'center'
					}, {
						field: "namecn",
						title: "资产名称",
						halign: 'center'
					}, {
						field: "organization",
						title: "购买机构",
						halign: 'center'
					}, {
						field: "refbankno",
						title: "关联账号",
						halign: 'center'
					}, {
						field: "cycle",
						title: "周期",
						halign: 'center'
					}, {
						field: "comment",
						title: "查询结果",
						halign: 'center'
					}]
				})
			}
		}
	
    </script>
</head>

<body>
    <div class="container-fluid">
        <div class="row">
            <div id="divSearchForm" class="col-md-10">
                <div>
                    <label for="spanCategoryGroup">资产分类：</label>
                    <span id="spanCategoryGroup">
                        <select id="selCategory1">
                            <option value="-1"> 全 部 </option>
                        </select>
                       
                    </span>
                </div>
                <div>
                    <label for="tbxAssetsName">资产名称：</label>
                    <input type="text" id="tbxAssetsName" />
                </div>
                <div>
                    <label for="tbxAssetsCode">资产编号：</label>
                    <input type="text" id="tbxAssetsCode" />
                </div>
                <div>
                    <label for="selFinanceType">资产类别：</label>
                    <select id="selFinanceType">
                        <option value="-1"> 全 部 </option>
                    </select>
                </div>
                <div>
                    <label for="tbxOrganization ">托管机构</label>
                    <input type="text" id="tbxOrganization " />
                </div>
                <div>
                    <label for="ckbAutoCycle">自动续期</label>
                    <input type="checkbox" id="ckbAutoCycle" />
                </div>
                <div>
                    <button type="button" id="btnSearch" class="btn-primary">
                        <span class="glyphicon glyphicon-search" /> 检索 Search </button>
                </div>
            </div>
            <div class="row">
                <div class="col-md-10">
                    <div id="toolsButtons">
                        <button type="button" id="btnAdd" class="btn-success">
                            <span class="glyphicon glyphicon-plus" /> 新增资产 Add
                        </button>
                        <button type="button" id="btnInstockShow" class="btn-primary">
                            <span class="glyphicon glyphicon-download-alt" /> 资产入库 Instock
                        </button>
                        <button type="button" id="btnEdit" class="btn-warning">
                            <span class="glyphicon glyphicon-edit" /> 编辑资产 Edit
                        </button>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-10">
                    <div id="divResult">
                        <table id="tblResult">
                            <thead>
                                <tr id="resultHeader">
                                    <th data-halign="center" data-valign="middle">
                                        <span class="glyphicon glyphicon-tags"> 资产编号
                                    </th>
                                    <th data-halign="center" data-valign="middle">资产名 称</th>
                                    <th data-halign="center" data-valign="middle"> 品 牌 </th>
                                    <th data-halign="center" data-valign="middle"> 型 号 </th>
                                    <th data-halign="center" data-valign="middle">周期 </th>
                                    <th data-halign="center" data-valign="middle">查询结果</th>
                                </tr>
                            </thead>
                            <tbody id="resultBody"></tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="divAssetsInstock" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content" id="content">
                        <div class="modal-header" id="assetsInstockHead">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>

                            <h4 class="modal-title" id="modalTitle">资产入库</h4>

                        </div>
                        <div class="modal-body">
                            <form id="formInstock">
                                <input type="hidden" id="hidAssetsIdForInstock" value="" />
                                <div id="divInstockAlert" role="alert"></div>
                                <div id="divInstockContent">
                                    <div>
                                        <label for="tbxAssetsNameShow">资产名称：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxAssetsNameForInstock" readonly="readonly" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockCount">入库数量：</label>
                                        <div class="input-group">
                                            <input type="number" min="0" id="tbxInstockCount" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockPrice">入库单价：</label>
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input type="number" min="0" id="tbxInstockPrice" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockSum">金额合计：</label>
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input type="text" readonly="readonly" min="0" id="tbxTotalPrice" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockDate">入库时间：</label>
                                        <div class="input-group">
                                            <input type="date" id="tbxInstockDate" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="selHandlerEmp">资产购置人：</label>
                                        <div class="input-group">
                                            <select id="selHandlerEmp" required="required"> </select>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxInstockComment">备注说明：</label>
                                        <div class="input-group">
                                            <textarea rows="2" id="tbxInstockComment"> </textarea>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        
                        <div class="modal-footer">
                            <button class="btn-primary" id="btnInstock">
                                <span class="glyphicon glyphicon-save"> 入库 Instock </button>
                            <button class="btn-default" data-dismiss="modal" id=" btnCancelInstock">
                                <span class="glyphicon glyphicon-remove"> 取消 Cancel
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="divForm" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="modalTitle">新增资产</h4>
                        </div>
                        <div class="modal-body form-inline">
                            <div class="form-group">
                                <label class="control-label" for="txtorganization">购买机构</label>
                                <input type="text" id="txtorganization" style="width: 200px;" class="form-control" />
                            </div>
                            <div class="form-group">
                                <label class="control-label" for="txtrefBankNo">关联账号</label>
                                <input type="text" id="txtrefBankNo" style="width: 200px;" class="form-control" />
                            </div>
                            <div class="form-group">
                                <label class="control-label" for="selFinanceType">资产分类</label>
                                <select id="selFinanceType"></select>
                            </div>

                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="button" class="btn btn-primary">保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade" id="divAssetsInfo" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
                aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content" id="assetsInfoContent">
                        <div class="modal-header" id="assetsInfoHead">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>
                            <h4 class="modal-title" id="modalTitle">资产信息</h4>
                        </div>
                        <div class="modal-body">
                            <form id="formAssetsInfo">
                                <input type="hidden" id="hidAssetsId" value="" />
                                <div id="divEditAlert" role="alert"></div>
                                <div id="divEditContent">
                                    <div>
                                        <label for="tbxAssetsCodeEdit">资产编号：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxAssetsCodeEdit" readonly="readonly" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxAssetsNameEdit">资产名称：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxAssetsNameEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="spanCategoryGroupEdit"> 资产分 类 : </label>
                                        <div class="input-group">
                                            <div>
                                                <select id="selCategoryEdit1" required="required"></select>
                                                <select id="selCategoryEdit2" required="required"></select>
                                            </div>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="selPackageTypeEdit">包装类型：</label>
                                        <div class="input-group">
                                            <select id="selPackageTypeEdit"></select>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxNormalBrandEdit">品牌：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxNormalBrandEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxNormalModelEdit">型号：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxNormalModelEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxSupplierEdit">供货商名称：</label>
                                        <div class="input-group">
                                            <input type="text" id="tbxSupplierEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxSupplierTelEdit">供货商电话：</label>
                                        <div class="input-group">
                                            <input type="tel" id="tbxSupplierTelEdit" required="required" />
                                            <span class="input-group-addon">
                                                <span class="glyphicon glyphicon-asterisk"></span>
                                            </span>
                                        </div>
                                    </div>
                                    <div>
                                        <label for="cbkConsumptiveEdit">耗材：</label>
                                        <div class="input-group">
                                            <input type="checkbox" id="cbkConsumptiveEdit" required="required" />
                                        </div>
                                    </div>
                                    <div>
                                        <label for="tbxCommentEdit">其他说明：</label>
                                        <div class="input-group">
                                            <textarea rows="2" id="tbxCommentEdit"> </textarea>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button class="btn-primary" id="btnSaveAssets">
                                <span class="glyphicon glyphicon-floppy-saved" /> 保 存 Save</button>
                            <button class="btn-default" data-dismiss="modal" id="btnCancel"> 90
                                <span class="glyphicon glyphicon-remove" /> 取 消 Cancel</button>
                        </div>
                    </div>
                </div>
            </div>



</body>

</html>